﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class bloodBar_script : MonoBehaviour {
    public float curBlood = 10f;
    private float targetBlood = 10f;
    private Rect bloodBarArea;
    private Rect addButton;
    private Rect minusButton;

	void Start () {
        bloodBarArea = new Rect(Screen.width - 200, 20, 180, 50);

        
        addButton = new Rect(Screen.width - 200, 50, 40, 20);
        minusButton = new Rect(Screen.width - 60, 50, 40, 20);
	}

    private void OnGUI() {
        if (GUI.Button(addButton, " + ")) addBlood(1);
        if (GUI.Button(minusButton, " - ")) desBlood(1);
        curBlood = Mathf.Lerp(curBlood, targetBlood, 0.1f);
        GUI.HorizontalScrollbar(bloodBarArea, 0f, curBlood, 0f, 10f);
    }

    public void addBlood(float num) {
        targetBlood = targetBlood + num > 10f? 10f : targetBlood + num;
    }

    public void desBlood(float num) {
        targetBlood = targetBlood - num < 0f? 0f : targetBlood - num;
    }
}